package binarysearchtree;

public class Test {
    public static void main(String[] args) {
//        先造一颗二叉搜索树
        BinarySearchTree binarySearchTree = new BinarySearchTree();
        binarySearchTree.insert(5);
        binarySearchTree.insert(3);
        binarySearchTree.insert(7);
        binarySearchTree.insert(2);
        binarySearchTree.insert(4);
        binarySearchTree.insert(6);
        binarySearchTree.insert(8);

//        删
        System.out.println("数据 4 删除前");
        TreeNode treeNode2 =  binarySearchTree.search(4);
        System.out.println(treeNode2 != null ? treeNode2.val : null);

        binarySearchTree.remove(4);
        System.out.println("数据 4 删除前");
        TreeNode treeNode3 =  binarySearchTree.search(4);
        System.out.println(treeNode3 != null ? treeNode3.val : null);


    }
}


//        System.out.println("查");
////        查
//                TreeNode treeNode =  binarySearchTree.search(4);
//                System.out.println(treeNode != null ? treeNode.val : treeNode);
//
//                TreeNode treeNode1 =  binarySearchTree.search(9);
//                System.out.println(treeNode1 != null ? treeNode1.val : null);
//
//
////        增
//                binarySearchTree.insert(9);